#pragma once
#include "order_processor_interfaces.h"
#include <atomic>
#include <shared_mutex>
#include <vector>

class CallbackDispatcherImpl : public ICallbackDispatcher {
public:
    CallbackDispatcherImpl();
    void registerCallback(std::shared_ptr<OrderCallback> callback) override;
    void notifyOrderStatus(const Order& order, OrderStatus status) override;
    void notifyTrade(const Trade& trade) override;
    void notifyError(const OrderError& error) override;

private:
    std::shared_mutex callbacksMutex_;
    std::vector<std::shared_ptr<OrderCallback>> callbacks_;
    std::atomic<bool> isNotifying_{false};
};